package com.monkar.java.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
import org.springframework.stereotype.Repository;


import com.monkar.java.bean.AlumnoDTO;
import com.monkar.java.bean.UsuarioDTO;
import com.monkar.java.constans.QuerysMySQL;
import com.monkar.java.constans.RowMapperConstans;

@Repository
public class AlumnoDAO {
	
	private SimpleJdbcTemplate simpleJdbcTemplate;
    private JdbcTemplate jdbcTemplate;
	private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
	
	@Autowired
	public void init(DataSource dataSource) {
		this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
		this.jdbcTemplate=new JdbcTemplate(dataSource);
		this.namedParameterJdbcTemplate=new NamedParameterJdbcTemplate(dataSource);
		
	} 
	
	
	@SuppressWarnings("unchecked")
	public List<AlumnoDTO> obtenerAlumnoXUsuario(UsuarioDTO usuario){
		System.out.println("ingreso al dao");
		
		String sql= QuerysMySQL.LISTAR_ALUMNOS;
		sql+=" and usuario='"+usuario.getUsuario()+"' and clave= md5('"+ usuario.getClave()+"')";
		System.out.println(sql);
		
		return this.jdbcTemplate.query(sql,new RowMapperConstans.AlumnoMapper());
		
	}

}
